package com.sparrow.domain.p;

import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

@CacheConfig(cacheNames = "spiders")
public interface SpiderRepository extends JpaRepository<Spider, Long> {

	@Cacheable
	Spider findByName(String name);


    @Query("from Spider u where u.name=:name")
    Spider findSpider(@Param("name") String name);
    
    @CachePut(key = "#p0.name")
    Spider save(Spider spider);


}
